<script setup>
import {Lock, User} from "@element-plus/icons-vue";
import {ref, reactive} from "vue";
import {post} from "@/http";
import {ElMessage} from "element-plus";
import router from "@/router";
let username = ref("");
let pwd = ref("");
const TandF=()=>{
    if (username.value == "" || username.value == null) {
      ElMessage.warning("请输入用户名")
  } else if (pwd.value == "" || pwd.value == null) {
      ElMessage.warning("请输入密码")
  }else {
      post("/registe/user",
          {username:username.value,pwd:pwd.value},
          (msg)=>{
        console.log('接收到注册数据'+msg);
        ElMessage.success(msg);
        router.push("/");
      });
    }
}
</script>
<template>
  <div style="position: absolute;height: 100%;width:100%;text-align: center">
    <div style="position: relative;width: 100%;margin-left:25%; text-align: left">
      <p style="width: 20%">用户名：</p>
      <el-input style="width: 50%" v-model="username">
        <template #prefix>
          <el-icon>
            <User/>
          </el-icon>
        </template>
      </el-input>
    </div>
    <div style="position: relative;width: 100%;margin-left:25%; text-align: left">
      <p style="width: 20%">密码：</p>
      <el-input style="width: 50%" v-model="pwd" type="password">
        <template #prefix>
          <el-icon>
            <lock/>
          </el-icon>
        </template>
      </el-input>
    </div>
    <el-button type="success" @click="TandF">立即注册</el-button>
  </div>
</template>
<style scoped>
</style>